import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import get from '@dfeidao/atom-mobile/local/get';
import set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import render from '@dfeidao/atom-mobile/render/render';

export default async function a005(fd: IFeidaoAiMobile, e: Event, page_no: number) {
	// onEndReached
	console.log('onEndReached', page_no);
	if (!page_no) { return; }
	const teacher_no = get(fd, 'teacher_no');
	const pre_d = get(fd, 'pre_d') as [];
	const d = await nodejs<{
		d: Array<{
			key: {};
		}>,
		total_size: number
	}>('app-student-list/s001', {
		filter: {
			teacher_no// : 'JS0004'
		},
		page_no
	});
	const data = [...pre_d, ...d.d];
	await set(fd, 'pre_d', data);
	render(fd, { d: data, page_no, new_len: d.d.length });
}
